package com.kongge.viewdisplayframeworklib.ui.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.kongge.viewdisplayframeworklib.R;

/**
 * author:kongge
 * date:2018/9/13
 * layout:
 * description:
 */

public class TabbarItemView  extends RelativeLayout {

    private TextView tvTitle;

    private View bottomLineView;

    public TabbarItemView(Context context) {
        super(context);
    }

    public TabbarItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        tvTitle = findViewById(R.id.textview);
        bottomLineView = findViewById(R.id.bottom_line);
    }

    public void setTitle(String title) {
        tvTitle.setText(title);
    }

    public void setSelected(boolean isSelected) {
        bottomLineView.setVisibility(isSelected ? VISIBLE : INVISIBLE);
        tvTitle.setTextColor(isSelected ?
                getResources().getColor(R.color.default_text_selected_color)
                : getResources().getColor(R.color.default_text_color));
        tvTitle.setTextSize(isSelected ?
                getResources().getDimensionPixelOffset(R.dimen.tabbar_text_size_selected)
                : getResources().getDimensionPixelOffset(R.dimen.tabbar_text_size));
    }

}
